// 1、首先获取当前目录下所有的文件；
///2、然后筛选出所有的vue文件;
const files = require.context('@/views/coding/base', true, /\.vue$/);

const pages = {};

files.keys().forEach((key) => {
  ///3、通过正则将文件名作为属性名来保存文件
  if (files(key).default.name === undefined) {
    return;
  };
  //console.log(files(key))
  pages[key.replace(/(\.\/|\.vue)/g, '')] = files(key).default;
});


let routes = [];
// 通过内置对象Object的keys方法来生成vue可用的路由数组
Object.keys(pages).forEach((item) => {
  console.log("item:"+item)
  routes.push({
    path: `/layout/${pages[item].name}`,
    name: pages[item].name,
    //component: pages[item],

    component: resolve => require([`@/views/coding/base/${item}.vue`],resolve),
  });
});

console.log("routes")
console.log(routes)
export default routes;

